import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class GUI_info extends JPanel implements ActionListener{
	ImageButton btStart;
	ImageButton btRank;
	ImageButton btHelp;
	Building b;
	
	public GUI_info(Building __b){
		this.b = __b;
		
		setLayout(null);
		
		GUI_infoBar infoBar = new GUI_infoBar();
		infoBar.setBounds(0, 0, 800, 50);
		add(infoBar);
	
		GUI_infoContext Context = new GUI_infoContext(this.b.getName(), this.b.getAddr(), this.b.getPhoneNo(), this.b.getComment(), this.b.getStar());
		Context.setBounds(0, 50, 800, 420);
		add(Context);	
		
	}
	
	public void actionPerformed(ActionEvent ae){
		Main.Navi.con.removeAll();
		
		GUI_menu Menu = new GUI_menu();
		Menu.setBounds(0, 0, 800, 500);
		Main.Navi.con.add(Menu);
		
		Main.Navi.con.validate();
	}
}
	

class GUI_infoBar extends JPanel implements ActionListener{
	Image img = null;
	
	public GUI_infoBar(){
		Toolkit kit = Toolkit.getDefaultToolkit(); 
		img = kit.getImage("images/bar.jpg");
		
		setLayout(null);

		JLabel lb = new JLabel("건물/상점 정보");
		lb.setBounds(310, 10, 200, 30);
		lb.setForeground(Color.white);
		lb.setFont(new Font("bold",Font.BOLD,30));
		add(lb);
		
		Image btimg_back[] = new Image[4];
		btimg_back[0] = kit.getImage("images/bt_back2.jpg"); 
		btimg_back[1] = kit.getImage("images/bt_back2.jpg"); 
		btimg_back[2] = kit.getImage("images/bt_back2.jpg"); 
		btimg_back[3] = kit.getImage("images/bt_back2.jpg"); 
		
		ImageButton bt_back = new ImageButton(btimg_back);
		bt_back.setBounds(10, 0, 70, 100);
		bt_back.addActionListener(this);
		add(bt_back);
				
	}
	protected void paintComponent(Graphics g){ 
		g.drawImage(img, 0, 0, 800, 100, this); 
	}
	public void actionPerformed(ActionEvent ae){
		Main.Navi.con.removeAll();
		
		GUI_navi Navi = new GUI_navi();
		Navi.setBounds(0, 0, 800, 100);
		Main.Navi.con.add(Navi);
		
		Main.Navi.con.validate();
	}
}
	


class GUI_infoContext extends JPanel{
	Image photo = null;
	Image star = null;
	int __star_length = -1;
	
	public GUI_infoContext(String name, String addr, String phone, String comment, int star_length){
		Toolkit kit = Toolkit.getDefaultToolkit(); 
		photo = kit.getImage("images/noimage.png");
		star = kit.getImage("images/star.png");
		__star_length = star_length;
		
		setLayout(null);

		Font bold = new Font("bold", Font.BOLD, 20);
		
    	JLabel lb_name = new JLabel("이름: "+name);
		lb_name.setBounds(350, 40, 500, 30);
		lb_name.setFont(bold);
		add(lb_name);
		
		JLabel lb_addr = new JLabel("주소: "+addr);
		lb_addr.setBounds(350, 80, 500, 30);
		lb_addr.setFont(bold);
		add(lb_addr);
			
		JLabel lb_phone = new JLabel("전화번호: "+comment);
		lb_phone.setBounds(350, 120, 500, 30);
		lb_phone.setFont(bold);
		add(lb_phone);
		
		JLabel lb_comment = new JLabel("댓글");
		lb_comment.setBounds(350, 160, 500, 30);
		lb_comment.setFont(bold);
		add(lb_comment);
		
		JLabel lb_comment1 = new JLabel("-"+comment);
		lb_comment1.setBounds(380, 200, 500, 30);
		lb_comment1.setFont(bold);
		add(lb_comment1);
		
		JLabel lb_comment2 = new JLabel("-");
		lb_comment2.setBounds(380, 240, 500, 30);
		lb_comment2.setFont(bold);
		add(lb_comment2);
		
	}
	protected void paintComponent(Graphics g){ 
		g.drawImage(photo, 50, 40, 250, 200, this); 
		int value=__star_length;
		for(int i=0;i<value;i++)
			g.drawImage(star, 50+i*50, 260, 40, 40, this);
	}
}

